package com.wei.web.middleware.retry.sequence;


import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @mbg.generated 表名: bee_send_kafka_message
 * @date 2021/06/11
 */
public interface BeeSendKafkaMessageMapper {

    /**
     * @mbg.generated
     */
    int insert(BeeSendKafkaMessageDO record);

    /**
     * @mbg.generated
     */
    @Master
    BeeSendKafkaMessageDO selectByPrimaryKey(Long id);

    /**
     * @mbg.generated
     */
    int updateByPrimaryKey(BeeSendKafkaMessageDO record);


    int updateSending(BeeSendKafkaMessageDO record);



    BeeSendKafkaMessageDO selectByTopicKeyAndMsgTopic(@Param("topicKey") String topicKey, @Param("msgTopic") String msgTopic);


    BeeSendKafkaMessageDO selectNextMessage(@Param("topicKey") String topicKey,
                                            @Param("msgTopic") String msgTopic,
                                            @Param("currentMsgId") Long msgId);


    List<BeeSendKafkaMessageDO> selectMessageForRetrySend(@Param("scanTime") Long scanTime);

    int updateStatusForRetry(@Param("topicKey") String topicKey, @Param("msgTopic") String msgTopic,
                             @Param("msgId") Long msgId, @Param("gmtModified") Long gmtModified);

    int updateSendStatusAndTryNum(BeeSendKafkaMessageDO record);

    /**
     * 删除一段时间以前的发送成功消息
     */
    int deleteOldSuccessMessages(@Param("gmtModified") Long gmtModified,
                                 @Param("pageSize") Integer pageSize);
}